package chapter03

import org.apache.log4j.{Level, Logger}
import org.apache.spark.{SparkConf, SparkContext}

object Test28_join {
  def main(args: Array[String]): Unit = {
    Logger.getLogger("org.apache.spark").setLevel(Level.WARN)
    val conf = new SparkConf().setMaster("local[*]").setAppName("sortByKey")
    val sc = new SparkContext(conf)
    val value = sc.makeRDD(List(("a", 12), ("d", 20), ("c", 30)))
    val value1 = sc.makeRDD(List(("a", 30), ("b", 10), ("c", 15)))
    val value2 = value.join(value1)
    println(value2.collect().toList)
    //左外链接
    val value3 = value.leftOuterJoin(value1)
    println(value3.collect().toList)
    //右外链接
    val value4 = value.rightOuterJoin(value1)
    println(value4.collect().toList)
    //全链接
    val value5 = value.fullOuterJoin(value1)
    println(value5.collect().toList)
  }
}
